import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'
import ChildLayout from '../views/product/index'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/home/index')
    }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/home',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'HomeIndex',
        component: () => import('@/views/home/index'),
        meta: { title: '首页', icon: 'user', roles: ['common'] }
      }
    ]
  },
  {
    path: '/home',
    component: Layout,
    meta: { title: '会议系统', icon: 'check', roles: ['sss'] },
    children: [
      {
        path: 'task-graphic',
        name: 'HomeTaskGraphic',
        component: () => import('@/views/home/taskGraphic'),
        meta: { title: '任务面板', icon: 'process', roles: ['sss'] }
      },
      {
        path: 'my-task',
        name: 'HomeMyTask',
        component: () => import('@/views/home/myTask'),
        meta: { title: '我的任务', icon: 'process', roles: ['sss'] }
      },
      {
        path: 'all-task',
        name: 'HomeAllTask',
        component: () => import('@/views/home/allTask'),
        meta: { title: '全部任务', icon: 'process', roles: ['sss'] }
      },
      {
        path: 'source',
        name: 'HomeSource',
        component: () => import('@/views/home/source'),
        meta: { title: '会议记录', icon: 'process', roles: ['sss'] }
      },
      {
        path: 'task',
        name: 'HomeTask',
        component: () => import('@/views/home/task'),
        meta: { title: '任务分配', icon: 'process', roles: ['sss'] }
      }
    ]
  },
  {
    path: '/market',
    component: Layout,
    meta: { title: '经营管理', icon: 'setting', roles: ['sss'] },
    children: [
      {
        path: 'project',
        name: 'marketProject',
        component: () => import('@/views/market/project'),
        meta: { title: '项目管理', icon: 'tree', roles: ['sss'] }
      },
      {
        path: 'sign',
        name: 'marketSign',
        component: () => import('@/views/market/sign'),
        meta: { title: '合同管理', icon: 'tree', roles: ['sss'] }
      },
      {
        path: 'contract',
        name: 'marketContract',
        component: () => import('@/views/market/contract'),
        meta: { title: '收款管理', icon: 'user', roles: ['sss'] }
      },
      {
        path: 'receival',
        name: 'marketReceival',
        component: () => import('@/views/market/receival'),
        meta: { title: '收款记录', icon: 'process', roles: ['sss'] }
      },
      {
        path: 'price',
        name: 'marketPrice',
        component: () => import('@/views/market/demo'),
        meta: { title: '商务报价', icon: 'process', roles: ['sss'] }
      },
      {
        path: 'customer',
        name: 'marketCustomer',
        component: () => import('@/views/market/customer'),
        meta: { title: '客户关系', icon: 'process', roles: ['sss'] }
      },
      {
        path: 'cooperator',
        name: 'marketCooperator',
        component: () => import('@/views/market/demo'),
        meta: { title: '合作单位', icon: 'process', roles: ['sss'] }
      },
      {
        path: 'projectRecover',
        name: 'marketProjectRecover',
        component: () => import('@/views/market/projectRecover'),
        meta: { title: '项目回收站', icon: 'process', roles: ['sss'] }
      }
    ]
  },
  {
    path: '/product',
    component: Layout,
    meta: { title: '生产管理', icon: 'setting', roles: ['sss'] },
    children: [
      {
        path: '/fuHua',
        name: 'FuHua',
        component: ChildLayout,
        meta: { title: '富华电力', icon: 'tree', roles: ['sss'] },
        children: [
          {
            path: 'taskAllot',
            name: 'fuHuaTaskAllot',
            component: () => import('@/views/product/fuHua/taskAllot'),
            meta: { title: '任务分配', icon: 'tree', roles: ['sss'] }
          },
          {
            path: 'myTask',
            name: 'fuHuaMyTask',
            component: () => import('@/views/product/fuHua/myTask'),
            meta: { title: '我的任务', icon: 'tree', roles: ['sss'] }
          },
          {
            path: 'evolve',
            name: 'fuHuaEvolve',
            component: () => import('@/views/product/fuHua/evolve'),
            meta: { title: '项目进度', icon: 'tree', roles: ['sss'] }
          }
        ]
      },
      {
        path: '/huaJian',
        name: 'HuaJian',
        component: ChildLayout,
        meta: { title: '华建电力', icon: 'tree', roles: ['sss'] },
        children: [
          {
            path: 'taskAllot',
            name: 'HuaJianTaskAllot',
            component: () => import('@/views/product/huaJian/taskAllot'),
            meta: { title: '任务分配', icon: 'tree', roles: ['sss'] }
          },
          {
            path: 'myTask',
            name: 'HuaJianMyTask',
            component: () => import('@/views/product/huaJian/myTask'),
            meta: { title: '我的任务', icon: 'tree', roles: ['sss'] }
          },
          {
            path: 'productTotal',
            name: 'HuaJianProductTotal',
            component: () => import('@/views/product/huaJian/productTotal'),
            meta: { title: '项目统计', icon: 'tree', roles: ['sss'] }
          },
          {
            path: 'evolve',
            name: 'HuaJianEvolve',
            component: () => import('@/views/product/huaJian/evolve'),
            meta: { title: '工程造价', icon: 'tree', roles: ['sss'] }
          },
          {
            path: 'report',
            name: 'HuaJianReport',
            component: () => import('@/views/product/huaJian/report'),
            meta: { title: '项目报表', icon: 'tree', roles: ['sss'] }
          }
        ]
      },
      {
        path: '/yuanTong',
        name: 'yuanTong',
        component: ChildLayout,
        meta: { title: '源通电力', icon: 'tree', roles: ['sss'] },
        children: [
          {
            path: 'taskAllot',
            name: 'yuanTongTaskAllot',
            component: () => import('@/views/product/yuanTong/taskAllot'),
            meta: { title: '任务分配', icon: 'tree', roles: ['sss'] }
          },
          {
            path: 'myTask',
            name: 'yuanTongMyTask',
            component: () => import('@/views/product/yuanTong/myTask'),
            meta: { title: '我的任务', icon: 'tree', roles: ['sss'] }
          },
          {
            path: 'evolve',
            name: 'yuanTongEvolve',
            component: () => import('@/views/product/yuanTong/evolve'),
            meta: { title: '工程进度', icon: 'tree', roles: ['sss'] }
          }
        ]
      }
      // {
      //   path: 'productTotal',
      //   name: 'productProductTotal',
      //   component: () => import('@/views/product/productTotal'),
      //   meta: { title: '项目统计', icon: 'tree' }
      // },
      // {
      //   path: 'taskAllot',
      //   name: 'productTaskAllot',
      //   component: () => import('@/views/product/taskAllot'),
      //   meta: { title: '项目分配', icon: 'tree' }
      // },
      // {
      //   path: 'evolve',
      //   name: 'productEvolve',
      //   component: () => import('@/views/product/evolve'),
      //   meta: { title: '项目进度', icon: 'tree' }
      // }
    ]
  },
  {
    path: '/setting',
    component: Layout,
    meta: { title: '系统设置', icon: 'setting', roles: ['sss'] },
    children: [
      {
        path: 'department',
        name: 'SettingDepartment',
        component: () => import('@/views/setting/department'),
        meta: { title: '部门设置', icon: 'tree', roles: ['sss'] }
      },
      {
        path: 'user',
        name: 'SettingUser',
        component: () => import('@/views/setting/user'),
        meta: { title: '员工设置', icon: 'user', roles: ['sss'] }
      },
      {
        path: 'password',
        name: 'SettingPassword',
        component: () => import('@/views/setting/password'),
        meta: { title: '更改密码', icon: 'process', roles: ['sss'] }
      }
    ]
  },
  {
    path: '/permission',
    component: Layout,
    meta: { title: '权限管理', icon: 'check', roles: ['common'] },
    children: [
      {
        path: 'part',
        name: 'PermissionPart',
        component: () => import('@/views/permission/part'),
        meta: { title: '角色管理', icon: 'process', roles: ['common'] }
      },
      {
        path: 'userPart',
        name: 'PermissionUserPart',
        component: () => import('@/views/permission/userPart'),
        meta: { title: '角色分配', icon: 'process', roles: ['common'] }
      },
      {
        path: 'auth',
        name: 'PermissionAuth',
        component: () => import('@/views/permission/auth'),
        meta: { title: '权限分配', icon: 'process', roles: ['common'] }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
